/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * datos.java
 *
 * Created on 18/05/2012, 11:12:41 AM
 */

package Agenda;
import java.io.*;

/**
 *
 * @author KAREL
 */
public class datos extends javax.swing.JFrame  implements Serializable{

    /** Creates new form datos */
    public datos() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel8 = new javax.swing.JLabel();
        btnagregar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        txtAP = new javax.swing.JTextField();
        txtAM = new javax.swing.JTextField();
        txtnombres = new javax.swing.JTextField();
        txtUrb = new javax.swing.JTextField();
        txtManz = new javax.swing.JTextField();
        txtlote = new javax.swing.JTextField();
        txtvia = new javax.swing.JTextField();
        txtDistrito = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        txtProvincia = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        areaLista = new javax.swing.JTextArea();
        jLabel12 = new javax.swing.JLabel();
        btnlistar = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();

        jLabel8.setText("jLabel8");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        btnagregar.setText("Serealizar");
        btnagregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnagregarActionPerformed(evt);
            }
        });
        getContentPane().add(btnagregar, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 130, -1, -1));

        jLabel1.setText("Apellido Paterno");
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 42, -1, -1));

        jLabel2.setText("Apellido MAterno");
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 83, -1, -1));

        jLabel3.setText("Nombres");
        getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 118, -1, -1));

        jLabel4.setText("Urbanizacion");
        getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 148, -1, -1));

        jLabel5.setText("Manzana");
        getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 176, -1, -1));

        jLabel6.setText("Lote");
        getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 202, -1, -1));

        jLabel7.setText("Nombre Via");
        getContentPane().add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 233, -1, -1));

        jLabel9.setText("Distrito");
        getContentPane().add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 268, -1, -1));
        getContentPane().add(txtAP, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 40, 110, -1));
        getContentPane().add(txtAM, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 80, 110, -1));
        getContentPane().add(txtnombres, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 110, 110, -1));
        getContentPane().add(txtUrb, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 140, 110, -1));
        getContentPane().add(txtManz, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 170, 110, -1));
        getContentPane().add(txtlote, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 200, 110, -1));
        getContentPane().add(txtvia, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 230, 110, -1));
        getContentPane().add(txtDistrito, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 260, 110, -1));

        jLabel10.setText("Datos Generales");
        getContentPane().add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(123, 11, -1, -1));

        jLabel11.setText("Provincia");
        getContentPane().add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 300, -1, -1));
        getContentPane().add(txtProvincia, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 300, 110, -1));

        areaLista.setColumns(20);
        areaLista.setRows(5);
        jScrollPane1.setViewportView(areaLista);

        getContentPane().add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 40, 200, 290));

        jLabel12.setText("Lista de Personas");
        getContentPane().add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 10, -1, -1));

        btnlistar.setText("Deserializar");
        btnlistar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnlistarActionPerformed(evt);
            }
        });
        getContentPane().add(btnlistar, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 170, 90, -1));

        jButton1.setText("agregar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 170, -1, -1));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    public void limpiar(){
        txtAM.setText("");
        txtAP.setText("");
        txtDistrito.setText("");
        txtManz.setText("");
        txtProvincia.setText("");
        txtUrb.setText("");
        txtlote.setText("");
        txtnombres.setText("");
        txtvia.setText("");
    }
   
    private void btnagregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnagregarActionPerformed
        // TODO add your handling code here:
//        Serializacion s = new Serializacion();
//        s.agregar(txtnombres.getText(), txtAP.getText(), txtAM.getText(),txtUrb.getText(),txtManz.getText(), txtlote.getText(), txtvia.getText(), txtDistrito.getText(), txtProvincia.getText());

         //CPersona Personita = new CPersona(new CNombre(txtnombres.getText(), txtAP.getText(),txtAM.getText()) ,new CDireccion(txtUrb.getText(),txtManz.getText(),txtlote.getText(),txtvia.getText(),txtDistrito.getText(),txtProvincia.getText()));

         //System.out.print(Personita.toString());
         
        String al= areaLista.getText().toString();
        System.out.print(al);
        //iniciar el proceso de serializacion
        //colocar los objetos a1 y a2 en disco

       Serializacion s = new Serializacion();
       s.Serealizar(al);
       
       
    }//GEN-LAST:event_btnagregarActionPerformed

    private void btnlistarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnlistarActionPerformed
        // TODO add your handling code here:
         String a1= " ";
        
       Deserializacion ds = new Deserializacion();
       ds.Deserializar(a1);
        
    }//GEN-LAST:event_btnlistarActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
         CPersona Personita = new CPersona(new CNombre(txtnombres.getText(), txtAP.getText(),txtAM.getText()) ,new CDireccion(txtUrb.getText(),txtManz.getText(),txtlote.getText(),txtvia.getText(),txtDistrito.getText(),txtProvincia.getText()));

      areaLista.append(Personita.toString());
      areaLista.append(System.getProperty("line.separator")); 
      
      limpiar();
    }//GEN-LAST:event_jButton1ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new datos().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea areaLista;
    private javax.swing.JButton btnagregar;
    private javax.swing.JButton btnlistar;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField txtAM;
    private javax.swing.JTextField txtAP;
    private javax.swing.JTextField txtDistrito;
    private javax.swing.JTextField txtManz;
    private javax.swing.JTextField txtProvincia;
    private javax.swing.JTextField txtUrb;
    private javax.swing.JTextField txtlote;
    private javax.swing.JTextField txtnombres;
    private javax.swing.JTextField txtvia;
    // End of variables declaration//GEN-END:variables

}
